﻿using IQIGame.Onigao.Framework;
using UnityEditor;
using UnityEditor.UI;

namespace IQIGame.Onigao.Game.Editors
{
    [CustomEditor(typeof(ExText))]
    [CanEditMultipleObjects]
    public class ExTextEditor : TextEditor
    {
        private SerializedProperty _isAutoI18N;
        private SerializedProperty _guid;

        protected override void OnEnable()
        {
            base.OnEnable();

            _isAutoI18N = serializedObject.FindProperty(nameof(_isAutoI18N));
            _guid = serializedObject.FindProperty(nameof(_guid));
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUILayout.PropertyField(_isAutoI18N);
            UnityEngine.GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("guid", _guid.longValue.ToString());
            if (UnityEngine.GUILayout.Button("重新分配"))
            {
                _guid.longValue = (target as ExText).GetAnGUID();
            }
            UnityEngine.GUILayout.EndHorizontal();
            serializedObject.ApplyModifiedProperties();
            base.OnInspectorGUI();
        }
    }
}
